'use strict';
const Service = require('egg').Service;

class MassageService extends Service {
    // 查询
    async finditem(id) {
        let data = await this.app.mysql.get("massage", { id: id });
        return data;
    }
    async findAll() {
        let data = await this.app.mysql.select("massage");
        return data;
    }
    async exit(item) {
        if (item) {

            return { code: 200, msg: "修改成功", data: await this.app.mysql.update("massage", item) }
        }
        else {
            return { code: 404, msg: "未找到该数据" }
        }

    }
    async add(body) {
        if (body) {
            await this.app.mysql.insert("massage", body);
            return {
                code: 200,
                msg: "添加成功",
            }
        }
        else {
            return {
                code: 404,
                msg: "添加失败",
            }

        }
    }
   async del(id){
       let data= await this.app.mysql.delete("massage",{id});
       if(data){
           return {code:200,msg:"删除成功"};
           
       }
       else{
        return {code:404,msg:"删除失败"};
       }
   }


}

module.exports = MassageService;